package com.taiyi.renaissancemall.ui.mine.collect;

import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.taiyi.renaissancemall.R;
import com.taiyi.renaissancemall.bean.CollectBean;
import com.taiyi.renaissancemall.ui.main.goodsdetail.GoodsDetailActivity;

import java.util.List;

public class MyCollectAdapter extends BaseQuickAdapter<CollectBean.CollectionlistBean, BaseViewHolder> {
    public MyCollectAdapter(int layoutResId, @Nullable List<CollectBean.CollectionlistBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, CollectBean.CollectionlistBean item) {
        ImageView img = helper.getView(R.id.iv);
        Glide.with(mContext).load(item.smallimgurl).into(img);
        helper.setText(R.id.titleTv, item.name);
        String bvPrice = "";
        if (item.bvprice == null || "".equals(item.bvprice) || "null".equals(item.bvprice)) {
            bvPrice = "0.0BV";
        } else {
            bvPrice = item.bvprice + "BV";
        }
        helper.setText(R.id.sanPriceTv, "￥" + item.sanfprice);
        ((TextView) helper.getView(R.id.sanPriceTv)).getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        helper.setText(R.id.bvPriceTv, bvPrice);
        TextView priceTv = helper.getView(R.id.priceTv);
//        price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        String price = mContext.getString(R.string.symbolMoney) + item.price;
        priceTv.setText(price);
        TextView hyPrice = helper.getView(R.id.memberPriceTv);
        String hy_Price = mContext.getString(R.string.symbolMoney) + item.hyprice;
        hyPrice.setText(hy_Price);
        ConstraintLayout constraintLayout = (ConstraintLayout) helper.getView(R.id.item_layout);
        constraintLayout.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //跳转商品详情
                Intent intent = new Intent(mContext, GoodsDetailActivity.class);
                intent.putExtra("commodityId", item.commodityid);
                mContext.startActivity(intent);
            }
        });
    }
}
